/*
 * @Author: YNT 2501512800@qq.com
 * @Date: 2022-10-30 00:54:01
 * @LastEditors: YNT 2501512800@qq.com
 * @LastEditTime: 2022-10-31 15:37:35
 * @FilePath: \洋安未来社区\pages\giveOutWebView\index.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
// pages/giveOutWebView/index.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
    url: '',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    let link = options.link
    if (link.startsWith('https://')) {
      wx.login()
        .then(({ code }) => {
          console.log(code)
          this.setData({
            url: options.link + `?authCode=${code}` + '_#jdsz',
          })
        })
        .catch((err) => {
          console.log(err)
        })
    }
    if (link.startsWith('#小程序:')) {
      wx.navigateToMiniProgram({
        shortLink: `${link}`,
        success(res) {},
      })
    }
  },

  onMessage: function (options) {},

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {},
})
